package com.itheima.mapper;

import com.itheima.annotation.AutoFill;
import com.itheima.entity.SysMenu;
import com.itheima.enumeration.OperationType;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SysMenuMapper {
    /**
     * 根据id查询菜单
     * @param pid
     * @return
     */
    @Select("select * from sys_menu where pid = #{pid}")
    List<SysMenu> selectByPId(int pid);

    /**
     * 添加菜单
     * @param sysMenu
     */
    @AutoFill(value = OperationType.INSERT)
    void insert(SysMenu sysMenu);

    /**
     * 删除菜单
     * @param id
     */
    @Delete("delete from sys_menu where id = #{id}")
    void deleteById(Integer id);

    /**
     * 根据id查询菜单
     * @param id
     * @return
     */
    @Select("select * from sys_menu where id = #{id}")
    SysMenu selectById(Integer id);

    /**
     * 修改菜单
     * @param sysMenu
     */
    @AutoFill(value = OperationType.UPDATE)
    void update(SysMenu sysMenu);
}
